function $(dom) {
    return document.querySelector(dom)
}

/**
 * 根据协议的多选框是否选中设置注册按钮状态
 */
function setSubmitButtonStatus() {
    var cbox = $('input[type="checkbox"]')
    var subtn = $('.submit')
    subtn.disabled = !cbox.checked
}
setSubmitButtonStatus()

/**
 * 根据手机号文本框中的文本，设置发送验证码按钮的状态
 */
function setSendCodeButtonStatus() {

    var pNum = document.querySelector("#phoneNumber")
    var verify = document.querySelector("#verify")

    verify.disabled = !(pNum.value.length === 11)
}

setSendCodeButtonStatus()

/**
 * 根据当前选中的爱好，设置已选择爱好文本
 */
function setSelectedLoves() {
    var selcet = document.querySelector("select")
    var loves = document.querySelector(".loves")
    var optionsSelectedText = []
    for (var i = 0; i < selcet.children.length; i++) {
        if (selcet.children[i].selected) {
            optionsSelectedText.push(selcet.children[i].innerText)
        }
    }
    loves.innerText = '已选择的爱好：' + optionsSelectedText.join(",")

    console.log(optionsSelectedText);

}

setSelectedLoves()

